Demo: Scoring a Logistic Regression Model (Self-Paced)
In this demonstration, you score a new data set using the score code from the logistic regression model that you created earlier. This enables you to add predictions from a trained model to a score data set.
Reminder: If you restarted your SAS session, or it has timed out due to inactivity, you must re-create the course libraries, LOCALLIB and VST. To do this, run the AssignLibrary flow.
- In SAS Viya, launch SAS Studio by clicking the Applications menu button (the three-by-three grid in the upper left corner), expand ANALYTICS LIFE CYCLE, and click Develop Code and Flows.
- In the navigation panel on the far left, click the Explorer button (second from top). Expand Files >Home > workshop > VST. Double-click AssignLibrary.flw to open it.
- Click the Run button on the flow toolbar.
Demo Steps
- Open the previously created flow Categorical Data Analysis.flw from the VST folder. We will add a program to this flow.
Still in the VST folder, double click on Scoring Logistic.sas and view the code.- The SAS Program contains the following code. It uses the score code from the logistic regression model to score the SCORE_PVA data set.
- The predictions are saved to the PVAScored data set:
data VST.PVAScored;
set VST.SCORE_PVA;
%include "/home/student/workshop/VST/logistic_score.sas";
run;
proc contents data=VST.PVAScored;
run;
- Click the + Code to Flow button and add the program to the previously saved Categorical Data Analysis flow. Navigate to the flow tab of Categorical Data Anlysis.flw.
- Right-click on the Scoring Logistic node and select Run node. Save the Categorical Data Analysis flow.
- Examine the Results as well as the Output Data tab. Note the variables P_response and I_response in both the Results and the Output Data tabs

Artial view of the output table (PVASCORED) is shown below:

The P_Response column shows the predicted probability of the target Response=Yes. The I_Response column is an indicator variable that takes the value of Yes when the value of P_Response is greater than or equal to 0.5 and No otherwise.
Note: Your output might show a different listing of scored data.